package com.xianbeiying.app.ckgl.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.loopj.android.http.TextHttpResponseHandler;
import com.xianbeiying.app.ckgl.MyApplication;
import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.bean.UrlBean;
import com.xianbeiying.app.ckgl.http.HttpCallBackUtil;
import com.xianbeiying.app.ckgl.http.HttpPostManger;
import com.xianbeiying.app.ckgl.model.GetModel;
import com.xianbeiying.app.ckgl.util.LogUtils;

import cz.msebera.android.httpclient.Header;

/**
 * 技术支持
 * */
public class TechnicalSupportActivity extends BaseActivity  implements HttpCallBackUtil{
    private ImageView iv_title_left;
    private TextView tv_title;
    private TextView tv_ts_content;
    private  ImageView img_logn;
    private  TextView tv_ts_ln;
    private TextView tv_ts_gs;
    private TextView tv_ts_yw;
    //电话
    private TextView ts_phone;
    private GetModel getModel;
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_technical_support);
        initView();
    }

    private void initView(){
        getModel=new GetModel(this);
        getModel.addResponseListener(this);
        webView=(WebView) findViewById(R.id.webView);
        iv_title_left = (ImageView) findViewById(R.id.iv_title_left);
        tv_title = (TextView) findViewById(R.id.tv_title);
        ts_phone=(TextView) findViewById(R.id.ts_phone);
        tv_title.setText("技术支持");
        iv_title_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        ts_phone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                Uri data = Uri.parse("tel:" +ts_phone.getText().toString().trim());
                intent.setData(data);
                startActivity(intent);
            }
        });
//        getModel.GETTechnology("techsupport",true);
        HttpPostManger.get("http://"+ MyApplication.IP+UrlBean.Techsupport + "techsupport", new TextHttpResponseHandler() {
            //获取成功
            @Override
            public void onSuccess(int i, Header[] headers, String s){
                LogUtils.e("技术支持","加载成功"+i+"======");
//                webView.getSettings().setJavaScriptEnabled(true);//是否支持动态加载js
//                webView.getSettings().setDefaultTextEncodingName("UTF-8");//编码方式
//                //以下两行代码是使网页能够自适屏
//                webView.getSettings().setUseWideViewPort(true);
//                webView.getSettings().setLoadWithOverviewMode(true);
//                webView.loadData(s, "text/html;charset=UTF-8", null);//加载网页

//                webView.loadDataWithBaseURL(null, s, "text/html",
//                        "utf-8", null);
                webView.getSettings().setDomStorageEnabled(true);//有可能是DOM储存API没有打开
                webView.getSettings().setBlockNetworkImage(false);
                webView.getSettings().setUseWideViewPort(false);
                webView.getSettings().setJavaScriptEnabled(true);
                webView.getSettings().setAllowFileAccess(true);
                webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
                webView.getSettings().setLoadsImagesAutomatically(true);////支持自动加载图片
                webView.loadDataWithBaseURL("http://"+ MyApplication.IP+":8080/", s, "text/html", "utf-8", null);
            }

            //获取失败
            @Override
            public void onFailure(int i, Header[] headers, String s, Throwable throwable) {
                Log.e("技术支持", "加载失败");
            }
        });
//        webView.loadUrl("http://"+ MyApplication.IP+":8080/CloudIIMS/notice/techsupport");
    }

    @Override
    public void onCallBackData(String url, Object content) {

    }
}
